#include <stdio.h>

#include "tlib_ip_limit.h"

int main(int argc ,char *argv[])
{
	char sErrMsg[200];
	int iRetCode;	
	int i,iKey,iMaxAccessCount,iLimitTimeInterval,iRecalTimeInterval,iAccessCount;
	
	
	if (argc<6){
		printf("Usage %s key MaxAccessCount LimitTimeInterval RecalTimeInterval ip \n",argv[0]);
		return -1;
	}
	
	iKey=atoi(argv[1]);
	if (iKey==0){
		printf("Invlalid key\n");
		return -1;
		
	}	
	
	iMaxAccessCount=atoi(argv[2]);
	iLimitTimeInterval=atoi(argv[3]);
	iRecalTimeInterval=atoi(argv[4]);
			
	
	
	iRetCode=TLib_IP_Limit_Init(iKey,iLimitTimeInterval,iRecalTimeInterval,iMaxAccessCount,0,sErrMsg);
	if (iRetCode!=0){
		printf("%s\n",sErrMsg);
		return -1;
	}	
	
	iRetCode=TLib_IP_Limit_Get_Status(argv[5],sErrMsg);
	if (iRetCode<0){
		printf("%s\n",sErrMsg);		
	}else if (iRetCode==1){
		printf("%s has been blocked \n",argv[5]);		
	}else{
		printf("%s has still active \n",argv[5]);		
	}	
	
	return 0;
}